package com.prs.crm.domain.crm;

import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;

import com.prs.crm.domain.Attachment;
import com.prs.crm.domain.BaseEntity;

@Entity
@Table(name="crm_liaison")
public class Liaison extends BaseEntity{

	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer id;
	@ManyToOne
	@OrderBy
	private Customer customer;
	@ManyToOne
	private LiaisonReason reason;
	@ManyToOne
	private LiaisonEvolve evolve;
	@ManyToOne
	private LiaisonWay way;
	@ManyToOne
	private Linkman linkman;	
	private Date liaisonTime;
	@ManyToOne(fetch=FetchType.LAZY)
	@Cascade({org.hibernate.annotations.CascadeType.ALL,org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
	private Attachment attach;
	@Lob
	private String content;
	private Date nextLiaison;
	private String state;
	private String remark;
	@OneToMany(mappedBy="liaison", fetch = FetchType.LAZY,cascade ={CascadeType.ALL})
	private Set<LiaisonCost> costs;
	@ManyToOne
	private Liaison upLiaison;
	private String flag;
	@OneToMany(fetch=FetchType.LAZY,mappedBy="liaison")
	private Set<LiaisonCritique> liaisonCritiques;
	
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public Customer getCustomer() {
		return customer;
	}
	public void setCustomer(Customer customer) {
		this.customer = customer;
	}
	public LiaisonReason getReason() {
		return reason;
	}
	public void setReason(LiaisonReason reason) {
		this.reason = reason;
	}
	public LiaisonEvolve getEvolve() {
		return evolve;
	}
	public void setEvolve(LiaisonEvolve evolve) {
		this.evolve = evolve;
	}
	public LiaisonWay getWay() {
		return way;
	}
	public void setWay(LiaisonWay way) {
		this.way = way;
	}
	public Linkman getLinkman() {
		return linkman;
	}
	public void setLinkman(Linkman linkman) {
		this.linkman = linkman;
	}
	public Date getLiaisonTime() {
		return liaisonTime;
	}
	public void setLiaisonTime(Date liaisonTime) {
		this.liaisonTime = liaisonTime;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public Date getNextLiaison() {
		return nextLiaison;
	}
	public void setNextLiaison(Date nextLiaison) {
		this.nextLiaison = nextLiaison;
	}
	public void setCosts(Set<LiaisonCost> costs) {
		this.costs = costs;
	}
	public Set<LiaisonCost> getCosts() {
		return costs;
	}
	public void setAttach(Attachment attach) {
		this.attach = attach;
	}
	public Attachment getAttach() {
		return attach;
	}
	public void setUpLiaison(Liaison upLiaison) {
		this.upLiaison = upLiaison;
	}
	public Liaison getUpLiaison() {
		return upLiaison;
	}
	public void setFlag(String flag) {
		this.flag = flag;
	}
	public String getFlag() {
		return flag;
	}
	public void setLiaisonCritiques(Set<LiaisonCritique> liaisonCritiques) {
		this.liaisonCritiques = liaisonCritiques;
	}
	public Set<LiaisonCritique> getLiaisonCritiques() {
		return liaisonCritiques;
	}
	
}
